﻿@using Kovan.Model.Entity.UserCenter;
@using Kovan.Model.ViewModel.UserCenter;
@{
    var item = Model as act_module;
    var ParentId = ViewBag.ParentId as long?;
    var menus = ViewBag.EMenu as List<Kovan.Model.ViewModel.EMenu>;
    var AuthorityCodes = ViewBag.AuthorityCodes as List<EAuthorityCode>;
    var Authoritys = ViewBag.Authoritys as List<act_authority> ?? new List<act_authority>();

    var IsUpdate = ViewBag.IsUpdate ?? false;
}
<div class="pageContent">
    <form method="post" action="@Url.Content("~/Manage/Module/SaveMenu")" class="pageForm required-validate"
    onsubmit="return Manage_Module.SaveMenu_Dialog(this, Manage_Module.dialogAjaxDone);">
    <div class="pageFormContent" layouth="56">
        <p>
            <label>
                菜单名称：</label>
            <input type="text" name="name" size="30" class="required" value="@item.name" />
            <input type="hidden" name="application_id" value="@item.application_id" />
            <input type="hidden" name="module_id" value="@item.module_id" />
        </p>
        <p>
            <label>
                排序：</label>
            <input type="text" name="sort_order" size="30" class="digits" alt="请输入数字" value="@item.sort_order" />
        </p>
        <p style="display: none;">
            <label>
                图标地址：</label>
            <input type="text" id="icon_url" name="" size="30" value="@item.icon_url" />
        </p>
        <p>
            <label>
                前端地址：</label>
            <input type="text" name="front_url" size="30" value="@item.front_url" />
        </p>
        <p>
            <label>
                后台地址：</label>
            <input type="text" size="30" name="url" value="@item.url" />
        </p>
        <p>
            <label>
                父级菜单：</label>
            <select name="parent_id">
                <option value="0">请选择</option>
                @if (ParentId > 0)
                {
                    foreach (var item2 in menus)
                    {
                    <option value="@item2.module.module_id"  @(ParentId == item2.module.module_id ? "selected" : "")>@item2.name2</option>
                    }
                }
            </select>
        </p>
        <p>
            <label>
                前端菜单：</label>
            <input type="checkbox" checked="checked" name="is_menu" value="1" @(item.is_menu == 1 ? "checked" : "") />
        </p>
        <p>
            <label>
                是否显示：</label>
            <input type="checkbox" checked="checked" name="is_view" value="1" @(item.is_view == 1 ? "checked" : "")  />
        </p>
        <p>
            <label>
                是否激活：</label>
            <input type="checkbox" checked="checked" name="enabled" value="1" @(item.enabled == 1 ? "checked" : "")  />
        </p>
        <dl class="nowrap" style="width: 98%">
            <dt>可选权限：</dt>
            <dd class="lab_none">
                @foreach (var authority in AuthorityCodes)
                {
                    var IsChecked = true;
                    if (IsUpdate)
                    {
                        IsChecked = Authoritys.Count(c => c.code == authority.code) > 0 ? true : false;
                    }
                    <label>
                        <input type="checkbox" name="authority" value="@authority.code" @(IsChecked ? "checked" : "") />@authority.name&nbsp;</label>
                }
            </dd>
        </dl>
        <dl class="nowrap" style="width: 98%">
            <dt>页面参数：</dt>
            <dd>
                <textarea name="menu_params" cols="77" rows="5"> @item.menu_params</textarea></dd>
        </dl>
        <dl class="nowrap" style="width: 98%">
            <dt>描述：</dt>
            <dd>
                <textarea name="description" cols="77" rows="5"></textarea></dd>
        </dl>
    </div>
    <div class="formBar">
        <ul>
            <!--<li><a class="buttonActive" href="javascript:;"><span>保存</span></a></li>-->
            <li>
                <div class="buttonActive">
                    <div class="buttonContent">
                        <button type="submit">
                            保存</button></div>
                </div>
            </li>
            <li>
                <div class="button">
                    <div class="buttonContent">
                        <button type="button" class="close">
                            取消</button></div>
                </div>
            </li>
        </ul>
    </div>
    </form>
</div>
